package demo.user.controller;


import demo.user.dto.MenuDTO;
import demo.user.pojo.Menu;
import demo.user.service.MenuService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author LonelySnow
 * @since 2020-06-15
 */
@RestController
public class MenuController {

    @Autowired
    private MenuService menuService;

    @GetMapping("/userMenu")
    @ApiOperation(value = "校验用户是都有访问某个路径的权限接口")
    @ApiResponses({
            @ApiResponse(code = 200, message = "用户具有改路径的访问权限"),
            @ApiResponse(code = 401, message = "用户没有访问该路径的权限")
    })
    public ResponseEntity<MenuDTO> getUserMenu(
            @ApiParam(value = "用户id", example = "1") @RequestParam("uid") Long uid,
            @ApiParam(value = "uri地址", example = "/api/test/list") @RequestParam("uri") String uri) {
        MenuDTO menuDTO = menuService.getUserMenu(uid, uri);
        return ResponseEntity.ok(menuDTO);
    }

}

